package com.zzl.alligator.management.vote.service.impl;


import com.zzl.alligator.management.vote.mapper.VoteUserSubjectMapper;
import com.zzl.alligator.management.vote.domain.VoteUserSubject;
import com.zzl.alligator.management.vote.service.IVoteUserSubjectService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
 * 投票人表(VoteUserSubject)服务层
 *
 * @author zhouziliang
 * @since 2020-07-23
 */
@Service
public class VoteUserSubjectService implements IVoteUserSubjectService {
    
    @Autowired
    private VoteUserSubjectMapper voteUserSubjectMapper;
    
    /**
     * 通过ID查询单条数据
     *
     * @param userId 主键
     * @return 实例对象
     */
    @Override
    public VoteUserSubject findVoteUserSubjectById(Long userId) {
        return voteUserSubjectMapper.findVoteUserSubjectById(userId);
    }

   /**
     * 通过实体作为筛选条件查询
     *
     * @param voteUserSubject 实例对象
     * @return 对象列表
     */
    @Override
    public List<VoteUserSubject> findVoteUserSubjectList(VoteUserSubject voteUserSubject) {
        return voteUserSubjectMapper.findVoteUserSubjectList(voteUserSubject);
    }

    /**
     * 新增数据
     *
     * @param voteUserSubject 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertVoteUserSubject(VoteUserSubject voteUserSubject) {
        return voteUserSubjectMapper.insertVoteUserSubject(voteUserSubject);
    }

    /**
     * 修改数据
     *
     * @param voteUserSubject 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateVoteUserSubject(VoteUserSubject voteUserSubject) {
        return voteUserSubjectMapper.updateVoteUserSubject(voteUserSubject);
    }

    /**
     * 通过主键删除数据
     *
     * @param userId 主键
     * @return 是否成功
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteById(Long userId) {
        return voteUserSubjectMapper.deleteById(userId);
    } 
    
}